package ch.ethz.inf.shop.model;

import java.sql.ResultSet;
import java.sql.SQLException;

import ch.ethz.inf.shop.Title;

/**
 * Object that represents a registered in user.
 */
public final class RegisteredUser {

	@Title(text = "User", isVisible = true)
	private final String name;
	@Title(text = "Password", isVisible = false)
	private final String password;
	@Title(text = "Email", isVisible = true)
	private final String email;
	@Title(text = "User ID", isVisible = false)
	private final int userId;

	@Override
	public String toString() {
		return name;
	}

	public RegisteredUser(final String name, final String password, final String email, final int user_id) {

		this.name = name;
		this.password = password;
		this.email = email;
		this.userId = user_id;
	}

	public RegisteredUser(ResultSet rs) throws SQLException {
		this.name = rs.getString("name");
		this.userId = rs.getInt("user_id");
		this.email = rs.getString("email");
		this.password = rs.getString("passwd");
	}

	public String getPassword() {
		return password;
	}

	public String getEmail() {
		return email;
	}

	public int getUserId() {
		return userId;
	}

	public String getName() {
		return name;
	}

}
